<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <button>Click Me</button>
</body>
<script>
//   基于 students 数组和 map()，编写匿名回调函数在 map()中调用，按如下要求处理 students 数据

// 以下面的格式为数组中的每个项目返回一个字符串： <name> :学号 <ID> 总分<score>排名第<rank>
// 将返回的数据存储在新的 studentsFullInfo 变量中
// 不要删除 musicData 变量
// 请勿更改任何 musicData 内容
          let students = [
            {name : "Susan",ID:1,score:'90',rank:6},
            {name : "Jackson",ID:2,score:'88',rank:7},
            {name : "Bob",ID:3,score:'45',rank:18},
            {name : "Jennie",ID:3,score:'99',rank:1},
            {name : "Amy",ID:3,score:'39',rank:21},
            {name : "Lisa",ID:3,score:'78',rank:8},  
        ];

        let studentsFullInfo = students.map(function(obj) {
        let narr = new Array();
        let str = obj.name + ':' + '学号' +obj.id + '总分' + obj.score + '排名第' + obj.rank
        narr.push(str)
        return narr;
      });
        console.log(studentsFullInfo);
        // ["Susan：学号1总分90排名第6", "Jackson：学号2总分88排名第7"...]

//         基于 students 数组和 filter()，编写匿名回调函数在 filter()中调用，按如下要求处理 students 数据

// 筛选出成绩不及格的学生，
// 将返回的数据存储在新的 failList 变量中

        let failList = students.filter(function(obj){
          let narr = new Array();
          let nobj = {}
          nobj[obj.name] = obj.ID
          narr.push(nobj)
          return nobj
        })

        console.log(failList);
        // [{name : "Bob",ID:3,score:'45',rank:18}, {name : "Amy",ID:3,score:'39',rank:21},]


        function merge(arr1){
          return function(arr2){
              var newArr = arr1.concat(arr2);
              return newArr.sort((a,b)=>a-b)
          }
      }

      //测试用例
      console.log(merge([1,5,8])([2,4])) // =>[1,2,4,5,8] 
      console.log(merge([6,9])([1,2])) // =>[1,2,6,9] 


      var btn = document.querySelector('button');

      btn.addEventListener("click", (function() {
        // init the count to 0
          var count = 0;
          return function(){
            count++
            console.log(count)
          }
        // your code here
      })());
</script>
</html>